{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "59d5171c-0a69-40de-b792-4a9265ae4b9c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import scipy\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import sympy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3a7d46bc-60e7-40ef-81f3-908e254fcb85",
   "metadata": {},
   "outputs": [],
   "source": [
    "status = {\n",
    "    'solid':0,\n",
    "    'level':7,\n",
    "    'skill':True,\n",
    "    'speed':0\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "40953731-bc21-4ba6-8a6e-992eea0615c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Status:\n",
    "    def __init__(self, **kwargs):\n",
    "        self.args = kwargs\n",
    "        self.solid = kwargs['solid']\n",
    "        self.level = kwargs['level']\n",
    "        self.skill = kwargs['skill']\n",
    "        self.speed = kwargs['speed']\n",
    "\n",
    "    def getStatus(self):\n",
    "        return self.args"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b4d15b7d-2a84-4f62-a5af-8631b5ed1b4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "st = Status(**status)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "cb22029b-95ce-48d3-a4ae-2e216525a429",
   "metadata": {},
   "outputs": [],
   "source": [
    "def getException(price, cost, day_cost, day_gain,loop,day_sow,cross_season,mul_ex,status):\n",
    "    days = 28 if not cross_season else 56\n",
    "    day_cost = np.floor(day_cost * (1 - status.speed))\n",
    "    day_left = days - day_cost\n",
    "    cnt = 0\n",
    "    gold_p = (3 + 10 * status.solid) / 300 + status.level * (6 + 5 * status.solid) / 300\n",
    "    sliver_p = max(gold_p * 2, 0.75) * (1 - gold_p)\n",
    "    normal_p = 1 - gold_p - sliver_p\n",
    "    #一次收获的期望\n",
    "    Ex = (normal_p + 1.2 * sliver_p + 1.5 * gold_p) * price * (0.1 * status.skill) * mul_ex\n",
    "\n",
    "    if day_left < 0:\n",
    "        return 0\n",
    "    if loop is True :\n",
    "        for i in range(days - day_left, days + 1, day_gain):\n",
    "            cnt += 1\n",
    "        total_ex = Ex * cnt - cost\n",
    "        d_ex = total_ex / day_left\n",
    "    else:\n",
    "        cnt = 1\n",
    "        total_ex = Ex - cost\n",
    "        d_ex = total_ex / day_left\n",
    "        \n",
    "    return cnt, day_cost, total_ex, d_ex\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "047e9843-3d2b-4640-bef1-92d175234a43",
   "metadata": {},
   "outputs": [],
   "source": [
    "def displayInfo(cnt, day_cost, total_ex, d_ex):\n",
    "    if cnt <= 1:\n",
    "        print(f'在{day_cost}天后收获\\n总获利{total_ex}\\n平均每日获利{d_ex}')\n",
    "    else:\n",
    "        print(f'还可以收获{cnt}次\\n总获利{total_ex}\\n平均每日获利{d_ex}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1fa3f6f-04fc-4a77-a806-00517574de96",
   "metadata": {},
   "outputs": [],
   "source": [
    "def getExByName(name, status, df):\n",
    "    \n",
    "    cnt, day_cost, total_ex,d_ex = getException(df.Price)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76ab2923-add7-417e-aef3-ed26f63ef16c",
   "metadata": {},
   "source": [
    " 金星几率 = (3+10*土壤品质)/300 + 耕作等级 * (6+5*土壤品质)/300"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "c0360add-214e-4bd1-b288-13e52c41e025",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "datas = pd.read_excel('./Datasets/StardewValley_Statistic.xlsx', index_col='Name')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
